$("#form-user-resetPwd").validate({
	rules : {
		password : {
			required : true,
			// remote : {
			// 	type : "post",
			// 	url : ctx + "admin/user/checkPassword",
			// 	data : {
			// 		oldPassword : function() {
			// 			return algorithmRequestParam($("#oldPassword").val());
			// 		}
			// 	}
			// }
		},
		newpassword1 : {
			required : true,
			minlength : 1,
			maxlength : 50
		},
		newpassword2 : {
			required : true,
			equalTo : "#newpassword1"
		}
	},
	messages : {
		password : {
			required : "请输入原密码",
			remote : "原密码错误"
		},
		newpassword1 : {
			required : "请输入新密码",
			minlength : "密码不能小于1个字符",
			maxlength : "密码不能大于50个字符"
		},
		newpassword2 : {
			required : "请再次输入新密码",
			equalTo : "两次密码输入不一致"
		}

	},
	focusCleanup : true
});

function submitHandler() {
	if ($.validate.form()) {
		$('#password').val(algorithmRequestParam($("#password").val()))
		$('#newpassword1').val(algorithmRequestParam($("#newpassword1").val()))
		$('#newpassword2').val(algorithmRequestParam($("#newpassword2").val()))
		// $.operate.save(api + "/admin/user/edit", $('#form-user-resetPwd').serialize());
		var user=$('#form-user-resetPwd').serializeObject();
		var info = JSON.parse(session.get('userInfo'))
		user.userId=info.userId;
		$.common.ajaxSimForm(
			api+"/admin/user/updateUserPwd",
			'put',
			user,
			function () {
				$.modal.reload()
				logOut()
			}
		)
	}
}

$(function () {
	var info = JSON.parse(session.get('userInfo'))
	applyDrawing('#form-user-resetPwd',info)
})